package org.jeecg.modules.flowerutil.controller;/**
 * @author gf
 * @create 2022-9-16 11:16
 */

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.flower.controller.FlowerAccountPeriodSwitchController;
import org.jeecg.modules.flower.entity.FlowerAccountPeriodSwitch;
import org.jeecg.modules.flower.service.IFlowerAccountPeriodSwitchService;
import org.jeecg.modules.flower.util.CommonUtil;
import org.jeecg.modules.flowerutil.PeriodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 *账期接口
 * @ClassName PeriodController
 * @description: TODO
 * @author gf
 * @datetime 2022年 09月 16日 11:16
 * @version: 1.0
 **/
@RestController
@Api(tags = "账期接口")
@RequestMapping("/flower/period")
public class PeriodController {
    @Autowired
    private IFlowerAccountPeriodSwitchService flowerAccountPeriodSwitchService;


/*    @GetMapping("getNowPeriod")
    @ApiOperation(value = "获取当前账期",notes = "获取当前账期")
    public String getNowPeriod() {
        PeriodUtils p =new PeriodUtils();
        return p.getNowPeriod();
    }*/


    /**
     * 返回上一个账期
     *
     * @return java.lang.String
     * @descriptionauthor
     * @author gf
     * 2022-9-16 9:25
     * []
     */
/*    @GetMapping("getPrePeriod")
    @ApiOperation(value = "获取上一个账期",notes = "获取上一个账期")
    public String getPrePeriod() {
        PeriodUtils p =new PeriodUtils();
        return p.getPrePeriod();
    }*/
    @GetMapping("getDefaultPeriod")
    @ApiOperation(value = "获取默认账期",notes = "获取默认账期")
    public String getDefaultPeriod(){
        PeriodUtils periodUtils = new PeriodUtils();
        String result=periodUtils.getDefaultPeriod();
        return result;
    }

    @GetMapping("getPeriodALL")
    @ApiOperation(value = "获取账期",notes = "获取账期")
    public List<String> getPeriodALL() {
        PeriodUtils periodUtils = new PeriodUtils();
        return periodUtils.getPeriod();
    }

    @GetMapping("getCurrentPeriod")
    @ApiOperation(value = "获取当前账期",notes = "获取当前账期")
    public String getCurrentPeriod(){
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM");
        //当前月
        String periodNow = formatter.format(calendar.getTime());
        return periodNow;
    }


    /**
     * 返回是否还行提醒
     *
     * @return java.lang.Integer
     * @descriptionauthor
     * @author gf
     * 2022-9-16 9:27
     * []
     */
/*    @GetMapping("getShowDay")
    @ApiOperation(value = "是否账期提示",notes = "是否账期提示")
    public ArrayList getShowDay() throws ParseException {




        PeriodUtils p = new PeriodUtils();
        ArrayList list =new ArrayList();
        if(p.getShowDay()){
            list.add(p.getNowPeriod());
            list.add( p.getPrePeriod());
        }
        return  list ;
    }*/

}